<include file="Public:header" />
<include file="Public:leftside" />

<div class="main-content">
	<div class="breadcrumbs breadcrumbs-fixed" id="breadcrumbs">
		<ul class="breadcrumb">
			<li> <i class="icon-home home-icon"></i> <a href="/">首页</a> </li>
			<li class="active">商城商品管理</li>
		</ul>
	</div>
	<div class="page-content">
	<div class="row panel-body" style="width: 100%;margin: 5px auto;padding: 15px 0;">
		<a href="{:U('Shop/index')}" class="btn btn-sm btn-primary">商品管理</a>
	
	</div>
    <div class="search_box">
    	<form id="mallSearch" action="__CONTROLLER__/index/" method="get" class="form-inline">
        	<section class="panel-default m-b-sm">
				<div class="alert alert-info">
					<p>
	                  <i class="fa fa-hand-o-right m-r-xs"></i><strong>操作提示</strong>
	                </p>
                    <p class="alert-p m-l-xl"><i class="fa fa-caret-right m-r-xs"></i>该页面展示了商城所有的商品信息，可对商品进行编辑修改操作。</p>
                    <p class="alert-p m-l-xl"><i class="fa fa-caret-right m-r-xs"></i>可输入商品名称关键字进行搜索。</p>
            	</div>
			</section>
        <div class="row padder-v">
		<div class="col-sm-4">
			<a href="__CONTROLLER__/add/" class="btn btn-sm btn-primary"><i class="fa fa-plus"></i> 添加商品 </a> 
			<a href="javascript:;" class="btn btn-sm btn-primary shop_type"><i class="fa fa-plus"></i> 商品导航分组 </a>
					
		</div>
		<div class="col-sm-2">
		<input type="text" name="id" value="<?=$_GET['id']?>" class="form-control input-sm" placeholder="请输入商品ID"/>
			
		</div>
		<div class="col-sm-2">
		<input type="text" name="title" value="{$_GET['title']|explode='_',###|implode=' ',###}" class="form-control input-sm" placeholder="请输入商品名称"/>

			
		</div>
		<div class="col-sm-2 shop_types" >
			<select class="input-sm form-control" id="shop_type" name="store_type_id" >
                    	<option value="-1" >请选择商品分组</option>  
                    	<option value="0" <eq name="_GET['store_type_id']" value="0">selected</eq>>无分组</option>
                    	{$categorys}
		    </select>			
		</div>


		<div class="col-sm-2">
			<button class="btn btn-sm btn-default" type="submit" >搜索</button>
			<a href="{:U('Shop/index')}" class="btn btn btn-info btn-sm" >清空</a>
			<button id="toexl" class="btn btn-sm btn-default" type="button" >导出</button>
		</div>
	</div>
     
        </form>
    </div>
    <div class="table-header" style="height:45px; line-height:45px; margin-top:10px;padding-right: 15px;">
        	<div style="float: left;">商品列表</div>
          <div class="fr">合计总数：<span class="font_orange font_bold">{$count}</span></div>
    </div>
    <div class="listContent">
    	<table class="table table-striped table-bordered table-hover" width="100%" border="0" cellpadding="0" cellspacing="0" >
            <thead>
        	<tr class="f_black bg_gray">
				<th style="width: 20px;">
					<input type="checkbox" class="ace" />
					<span class="lbl"></span>
				</th>
                <th style="width: 50px;" align="center">ID</th>
                <th style="width: 30%;">商品名称</th>
               	<th>库存</th>
                <th>原价</th>
                <th>售价</th>
                <th>店铺名</th>
                <th>发布时间</th>
                <th>商品分组</th>
                <th>商品状态</th>
                <th>是否开团</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <volist name="array" id="row">
	            <tr class="list" id="list{$row['id']}">
            		<td><input type="checkbox" name="id[]" class="ace aceid" value="{$row.id}" />
								<span class="lbl"></span></td>
                	<td>{$row.id}</td>
		            <td style="text-align:left;">{$row.title}</td>
		            <td>{$row.num}</td>
		            <td>{$row.oprice}</td>
		            <td>{$row.price}</td>
		            <td>{$row.storename}</td>
		            <td>{$row.addtime|date='Y-m-d H:i',###}</td>
		            <td>
						<php>
							$store_type=get_shop_type($row['store_type_id']);
						</php>
						<foreach name="store_type" item="v" key="k">
							<neq name="k" value="0">,</neq>
							{$v.label}

						</foreach>
					</td>
		          
		            <td><?=$row['ishidden'] == '0'?'上架中':($row['ishidden'] == '1'?'已下架':($row['ishidden'] == '2'?'已删除':'无货'))?></td>
		             <td><?=$row['tuanselect'] == '0'?'未开启':'<span style="color:red">开团中</span>	'?></td>
	                <td>
	                	<div class="dropdown">
	  						<button class="btn btn-info btn-sm dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
	    						请选择操作项
	    						<span class="caret"></span>
	  						</button>
							<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
								<li><a href="{:U('Shop/add',array('id'=>$row['id']))}">操作商品</a></li>
		                        <if condition="$jsonArray[CONTROLLER_NAME][strtolower(ACTION_NAME)] or $jsonArray[CONTROLLER_NAME][ACTION_NAME] or $userArray['isadmin'] == '1' " >
			                    <li><a href="javascript:;" ishidden="<?=$row['ishidden'] =='0'?'1':'0'?>" data="{$row['id']}" class="delTicket"><?=$row['ishidden'] =='0'?'下架':'上架'?>商品</a></li>
			                    <li><a href="javascript:;" ishidden="2" data="{$row['id']}" class="delTicket">删除商品</a></li>
			                 
		                        </if>
							    <li><a href="{:U('shop/index@www.58daiyan.com','id='.$row['id'])}" target="_blank">查看商品</a></li>
		                        <if condition="$row.is_updated eq 1">
		                        <li><a href="javascript:;" ajax="1" class="aclick" url="/Mall/updated/id/{$row.id}">已复查</a></li>
		                        </if>
                                
		                      <li><a href="javascript:;" nice="<?=$row['isindex'] =='0'?'1':'0'?>" data="{$row['id']}" class="niceTicket"><?=$row['isindex'] =='0'?'推荐':'取消推荐'?></a></li>
							</ul>
						</div>
	                </td>
	            </tr>
	        </volist>
            </tbody>
        </table>
        <div class="paging">{$page}</div>
    </div>
   </div>
</div>
<div class="col-sm-2 shop_types2"  style="display: none;">
	<select class="input-sm form-control" id="shop_type" name="store_type_id[]" multiple style="height: 250px;">
		<option value="-1" >请选择商品分组</option>
		<option value="0" <eq name="_GET['store_type_id']" value="0">selected</eq>>无分组</option>
		{$categorys}
	</select>
</div>
<script type="text/javascript">
$(document).ready(function(){
	$("#toexl").click(function(){		
		var action  = "/Shop/getProExl/";	
		$("#mallSearch").attr("action",action);
		$("#mallSearch").submit();	
	});
	$("#tosea").click(function(){		
		var action  = "/Shop/<?=ACTION_NAME?>/";	
		$("#mallSearch").attr("action",action);
		$("#mallSearch").submit();	
	});
    //删除商品
    $('.delTicket').click(function(){
        var url =   '/Shop/delete/';
        var e   =   $(this);
        var ishidden    =   e.attr('ishidden');
        var string  =   ishidden == '2'?'删除':(ishidden == '1'?'下架':(ishidden == '3'?'设置为无货':'上架'));
        layer.confirm('确定执行'+string+'商品吗?',{
                btn: ['确定', '取消']},
                function(){
                    $.get(url,{id:e.attr('data'),ishidden:e.attr('ishidden')},function(data){
            			layer.msg(data,function(){
                            location.reload();
                        });
                    });
                }
			);
    });
	 $('.niceTicket').click(function(){
        var url =   '/Shop/nice/';
        var e   =   $(this);
        var nice    =   e.attr('nice');
        var string  =   nice == '0'?'取消推荐':'推荐';
        layer.confirm('确定执行'+string+'商品吗?',{
                btn: ['确定', '取消']},
                function(){
                    $.get(url,{id:e.attr('data'),isnice:e.attr('nice')},function(data){
            			layer.msg(data,function(){
                            location.reload();
                        });
                    });
                }
			);
    });
	$('body').delegate('#getType,#changeTypeList','click',function(){
		var stringFlag	=	'';
		$('.aceid:checked').each(function(){
			stringFlag	+=	stringFlag?','+$(this).val():$(this).val();
		});
		console.log(stringFlag);
		$('#typeString').val(stringFlag);
		$.get('/Shop/copyConfigHtml',{keywords:$('#keywords').val()},function(data){
			layer.closeAll();
			layer.open({
				type:1,
				area:['80%','auto'],
				content:data
			});
		});
	});
	
	$('body').delegate('.ajaxListTicketType li','click',function(){
		var type_id = $(this).attr('databids');
		layer.confirm('确定要移动到该分类',function(){
			$.get('/Shop/changeType',{type_id:type_id,ticket_id:$('#typeString').val()},function(data){
			layer.closeAll();
			var dataArray	=	data.split('|||');
			layermsglink(dataArray[1],dataArray[2]);
		});
		},function(){});
		
	});
	$('body').delegate('.shop_type','click',function(){
		
		var adIds = "";  
        $("input:checkbox:checked").each(function(i){  
        	if($(this).val()!='on'){
        		 if(0==i){  
	                adIds = $(this).val();  
	            }else{  
	                adIds += (","+$(this).val());  
	            } 
        	}
            
           
        }); 
    
		var shop_types='<div style="width: 90%;margin: 50px auto;"> <form action="/Shop/shop_type_set.html" method="post" class="form form-horizontal" role="form">';
		shop_types+=$('.shop_types2').html();
		shop_types+='<input type="hidden" name="adids"  value="'+adIds+'" />';
		shop_types+='<div  style="padding: 13px 0;float: right;"><div style="font-size: 12px;color: #f00;">windows：按住 Ctrl 按钮来选择多个选项,Mac：按住 command 按钮来选择多个选项</div><button class="btn-small formSubmit" id="form" type="button" style="\n' +
            '    float: right;\n' +
            '    background: #eee;\n' +
            '    border: navajowhite;\n' +
            '    padding: 6px 16px;\n' +
            '"><i class="icon-ok bigger-110"></i>提交</button></div></form></div>';
			if(adIds){
				layer.open({
				  type: 1,
				  skin: 'layui-layer-rim', //加上边框
				  area: ['420px', '440px'], //宽高
				  title:'商品分组',
				  content: shop_types
				});
			}else{
				layer.alert('请先选择商品！')
			}
			
	});

    
});
</script>
<include file="Public:footer" />